#include <stdio.h>  
  
struct node {  
    int x, y;  
} num[5][5];  
int leap_year( int );  
int year_days( int );  
int days(int, int, int);  
  
int leap_year( int year ) { // 判断闰年或平年  
    return ( (year % 4 == 0 && year % 100 != 0) || year % 400 == 0 ) ? 1 : 0;  
}  
  
int year_days(int year) {   // 计算一整年的天数  
    return leap_year( year ) ? 366 : 365;  
}  
  
int days( int year, int month, int day ) { // 计算该天month,day 是本年year的第几天  
    int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, i;  
  
    if  ( leap_year( year ) && month > 2 )  
        day++;  
  
    for ( i = 1; i < month; i++ )  
        day += months[i];  
  
    return day;  
}  
  
int month[12] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304};  
  
int main() {  
    num[0][0].x = 3;  
    num[0][0].y = 8;  
    num[0][1].x = 4;  
    num[0][1].y = 9;  
    num[0][2].x = 5;  
    num[0][2].y = 0;  
    num[0][3].x = 1;  
    num[0][3].y = 6;  
    num[0][4].x = 2;  
    num[0][4].y = 7;  
    for (int i = 1; i < 5; i++) {  
        num[i][0].x = num[i - 1][4].x;  
        num[i][0].y = num[i - 1][4].y;  
        for (int j = 1; j < 5; j++) {  
            num[i][j].x = num[i - 1][j - 1].x;  
            num[i][j].y = num[i - 1][j - 1].y;  
        }  
    }  
    int y1 = 2012, m1 = 4, d1 = 9, y2, m2, d2, x, ans;  
    if (scanf("%d%d%d", &y2, &m2, &d2));  
    if (y1 == y2)  
        ans = days(y2, m2, d2) - days(y1, m1, d1);  
    else {  
        ans = 0;  
        for (int i = y1 + 1; i < y2; i++)  
            ans += year_days(i);  
        ans = year_days(y1) + days(y2, m2, d2) - days(y1, m1, d1) + ans;  
    }  
    x = (y2 - 1900) % 4 == 0 ? m2 <= 2 ? -1 : 0 : 0;  
    m2 = month[m2];  
    d2 += (y2 - 1900) / 4 - (y2 - 1900) / 100 + (y2 - 1900) / 400;  
    int day = ((y2 - 1900) * 365 + m2 + d2 + 1 + x) % 7;  
    ans += 2;  
    ans %= 455;  
    if (day < 1 || day > 5)  
        printf("Free.\n");  
    else  
        printf("%d and %d.\n", num[ans / 91][day - 1].x, num[ans / 91][day - 1].y);  
    return 0;  
}  